/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package FileInformation.helpers;

import FileInformation.utils.ExtensionType;
import java.io.File;
import java.io.Serializable;

/**
 *
 * @author Nobody
 */
public class ExtensionRetriever extends AbstractFileHelper implements Serializable {

 
    private String extension;
    private ExtensionType extensionType;

    public String getExtension() {
        return extension;
    }

    public ExtensionRetriever(File file) {
        super(file);
    }

    @Override
    public void execute() {
        String fullPath = file.getAbsolutePath();
        int dot = fullPath.lastIndexOf(".");
        extension = fullPath.substring(dot + 1);
        extensionType = ExtensionType.convertFromExtension(extension);
    }

    public boolean isExcelFile() {
        execute();
        return extensionType.equals(extensionType.XLS) || extensionType.equals(extensionType.XLSX);
    }

    public boolean isExcel7File() {
        execute();
        return extensionType.equals(extensionType.XLSX);
    }

    public boolean isGdaFile() {
        execute();
        return extensionType.equals(extensionType.GDA);
    }

    public boolean isExcel2003File() {
        execute();
        return  extensionType.equals(extensionType.XLS);
    }

    public boolean isCsvFile() {
        execute();
        return  extensionType.equals(extensionType.CSV);
    }
}
